cd "C:\Users\cham3\Dropbox\McLean_Yu_Sanctions\data\jss_submission"
use "JSS_submission_data.dta"

xtset ccode year

/* Table 1 */

qui xtpcse lnmilexp_wb L.all_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb, c(psar1) pairwise
est store m1

qui xtpcse lnmilper_wb L.all_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilper_wb, c(psar1) pairwise
est store m2

qui xtpcse lntiv_exp L.all_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_exp, c(psar1) pairwise
est store m3
qui xtpcse lntiv_imp L.all_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_imp, c(psar1) pairwise
est store m4

esttab m1 m2 m3 m4 


/* Table 2 */

qui xtpcse lnmilexp_wb L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb, c(psar1) pairwise
est store m1

qui xtpcse lnmilper_wb L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilper_wb, c(psar1) pairwise
est store m2

qui xtpcse lntiv_exp L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_exp, c(psar1) pairwise
est store m3

qui xtpcse lntiv_imp L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_imp, c(psar1) pairwise
est store m4

esttab m1 m2 m3 m4 


/* Figure 2 */

qui xtpcse lnmilexp_wb L.comp_sanc L.targ_sanc civilwar_ong L.lngdp L.polity2 L.lnmilexp_wb if conflict == 1, c(psar1) pairwise
est store m_war

qui xtpcse lnmilexp_wb L.comp_sanc L.targ_sanc civilwar_ong L.lngdp L.polity2 L.lnmilexp_wb if conflict == 0, c(psar1) pairwise
est store m_nowar

coefplot m_nowar m_war, ///
    keep(L.comp_sanc L.targ_sanc) ///
    rename(L.comp_sanc = "CompSanc" L.targ_sanc = "TargSanc") ///
    drop(_cons) ///
    legend(label(4 "War") label(2 "No War") position(3) rows(2)	region(lcolor(none))) ///
    xline(0, lpattern(dash)) ///
    ylabel(, angle(horizontal)) ///
    bylabel(, size(medium)) ///
    graphregion(color(white)) ///
    plotregion(color(white))


/* Table 3 */

global ind_sanc L.trade L.arms L.military L.financial L.travel L.other

qui xtpcse lnmilexp_wb $ind_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb, c(psar1) pairwise
est store m1

qui xtpcse lnmilper_wb $ind_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilper_wb, c(psar1) pairwise
est store m2

qui xtpcse lntiv_exp $ind_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_exp, c(psar1) pairwise
est store m3

qui xtpcse lntiv_imp $ind_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_imp, c(psar1) pairwise
est store m4

esttab m1 m2 m3 m4 


/* Appendix */

/* Table A1*/

gen lagged_all_sanc = L.all_sanc
gen lagged_comp_sanc = L.comp_sanc
gen lagged_targ_sanc = L.targ_sanc
gen lagged_lngdp = L.lngdp
gen lagged_polity2 = L.polity2
gen lagged_trade = L.trade
gen lagged_arms = L.arms
gen lagged_military = L.military
gen lagged_financial = L.financial
gen lagged_travel = L.travel
gen lagged_other = L.other

xtpcse lntiv_exp L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lntiv_exp, c(psar1) pairwise
gen in_sample = e(sample)

asdoc sum lntiv_exp lntiv_imp lagged_all_sanc lagged_comp_sanc lagged_targ_sanc lagged_trade lagged_arms lagged_military lagged_financial lagged_travel lagged_other conflict civilwar_ong lagged_lngdp lagged_polity2 if in_sample, ///
   stat(N mean p50 sd min max) save(descriptive_stats.doc) replace
   
xtpcse lnmilexp_wb L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb, c(psar1) pairwise
gen in_sample2 = e(sample) 

asdoc sum lnmilexp_wb  if in_sample2, stat(N mean p50 sd min max) save(descriptive_stats.doc)

xtpcse lnmilper_wb L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilper_wb, c(psar1) pairwise
gen in_sample3 = e(sample) 

asdoc sum lnmilper_wb  if in_sample3, stat(N mean p50 sd min max) save(descriptive_stats.doc)


/* Table A2*/

qui sureg (soc_exp_ln L.comp_sanc L.targ_sanc conflict civilwar_ong L.lnpop  L.lngdp  L.polity2 L.soc_exp_ln ) (lnmilexp_wb L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb ), corr 
est store m1

esttab m1 

heckman lnmilexp_wb L.comp_sanc L.targ_sanc conflict civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb, select(targ_dummy = L.conflict L.civilwar_ong L.lngdp  L.polity2 L.lnmilexp_wb L.lnsender_gdp) vce(cluster ccode) nolog

